<?php
/**
 * Desc:
 * User: aniu
 * Date: 2020/12/27
 * Time: 上午11:11
 * @return
 */

namespace App\Http\Controller;

use App\Model\Entity\UserDd;
use Swoft\Bean\BeanFactory;
use Swoft\Config\Annotation\Mapping\Config;
use Swoft\Db\DB;
use Swoft\Http\Message\Response;
use Swoft\Http\Server\Annotation\Mapping\Controller;
use Swoft\Http\Server\Annotation\Mapping\RequestMapping;
use function MongoDB\BSON\fromJSON;

/**
 * Class BeanController
 *
 * @since 2.0
 *
 * @Controller()
 */
class IndexController
{

    /**
     * 配置文件注解使用方法
     * @Config("app")
     * @var array
     */
    private $value = [];

    /**
     * @RequestMapping("index")
     *
     * @return string
     */
    public function index()
    {
        return 'test';
    }


    /**
     * @RequestMapping("test")
     * Desc:
     * User: aniu
     * Date: 2020/12/27
     * Time: 下午2:51
     */
    public function test(Response $response)
    {
        $list = DB::table('user_dd')->where(['uid'=>1])->get();
//        $list = UserDd::where(['uid'=>1])->get();
        return $response->withData(array('code'=>200, 'msg'=>'success', 'data'=>$list));
    }


    /**
     * @RequestMapping("config")
     * Notes:测试配置文件
     * User: aniu
     * DateTime: 2020/12/29 17:55
     */
    public function configtest()
    {
        // 测试配置文件
        $aliaes = \Swoft::getAlias('@app');
        var_dump($aliaes);
    }
}
